blob: 3f057437b723e7247f2cf74122624083a8d8170c [file] [log] [blame] [raw]
ifeq ($(CC),cc)
CC := gcc
endif
CFLAGS += -Wall -Os -fPIC
TARGETS := privilege-mac-priv.so privilege-solaris.so
KERNEL_NAME = $(shell uname -s)
ifeq ($(findstring FreeBSD,$(KERNEL_NAME)),FreeBSD)
default: privilege-mac-priv.so
else ifeq ($(KERNEL_NAME),SunOS)
default: privilege-solaris.so
else
default:
@printf "No default target for '%s'.\\nUse '%s <target> [...]' for cross-building; where targets are:\\n" "$(KERNEL_NAME)" "$(MAKE)"
@for i in $(TARGETS); do echo " $$i"; done
endif
ifdef WITH_BASH_SOURCE
ifndef WITH_BASH_BUILD
WITH_BASH_BUILD := $(WITH_BASH_SOURCE)
endif
SED ?= sed
BASH_HEADERS := builtins.h shell.h config.h config-top.h config-bot.h command.h stdc.h general.h alias.h bashtypes.h chartypes.h xmalloc.h bashansi.h bashjmp.h posixjmp.h syntax.h error.h variables.h array.h assoc.h hashlib.h conftypes.h arrayfunc.h quit.h sig.h maxpath.h unwind_prot.h dispose_cmd.h make_cmd.h ocache.h subst.h pathnames.h externs.h bashgetopt.h
BASH_HEADERS := $(addprefix build/bash/,$(BASH_HEADERS))
CFLAGS += -I build
privilege.o list.o mac-priv.o solaris.o: build/bash $(BASH_HEADERS)
clean: clean-build-headers
build/bash:
mkdir -p $@
build/bash/bashgetopt.h: $(WITH_BASH_SOURCE)/builtins/bashgetopt.h
$(SED) 's/^#include <stdc\.h>/#include "stdc\.h"/' $< > $@
build/bash/%.h: $(WITH_BASH_BUILD)/%.h
ln -s $< $@
build/bash/%.h: $(WITH_BASH_SOURCE)/%.h
ln -s $< $@
build/bash/%.h: $(WITH_BASH_SOURCE)/include/%.h
ln -s $< $@
clean-build-headers:
rm -f $(BASH_HEADERS)
endif
privilege-mac-priv.so: privilege.o list.o mac-priv.o
$(CC) $(LDFLAGS) --shared $^ -o $@ $(LIBS)
privilege-solaris.so: privilege.o list.o solaris.o
$(CC) $(LDFLAGS) --shared $^ -o $@ $(LIBS)
clean:
rm -f *.o $(TARGETS)