Define segments and make other adjustments in makefile.

At this point, hush can successfully build and run, although it doesn't work correctly.

The main Makefile is now dedicated to the GNO build. There's now a separate makefile for building on modern systems with GCC/Clang.
This commit is contained in:
Stephen Heumann 2014-11-05 22:26:33 -06:00
parent 77ded3c27c
commit 2669183517
4 changed files with 152 additions and 42 deletions

109
Makefile
View File

@ -1,65 +1,87 @@
SRCS = \
shell/hush.c \
# The *_SRC variables are used to define segments; see the "%.a" recipe.
# shell/hush.c is divided into segments as specified within the file itself.
MAIN_SRC = shell/hush.c
SHELL_OTHER_SRC = \
shell/match.c \
shell/math.c \
shell/random.c \
shell/shell.common.c \
shell/glob.c \
shell/glob.c
COREUTILS_SRC = \
coreutils/echo.c \
coreutils/test.c \
coreutils/test.ptr.hack.c \
libbb/xfuncs.printf.c \
libbb/xfuncs.c \
libbb/xgetcwd.c \
libbb/getopt32.c \
libbb/perror.msg.c \
libbb/xatonum.c \
libbb/signal.names.c \
libbb/ptrtoglobals.c \
libbb/error.retval.c \
libbb/xfunc.die.c \
libbb/safe.strncpy.c \
coreutils/test.ptr.hack.c
LIBBB_A_SRC = \
libbb/lineedit.c \
libbb/lineedptrhack.c \
libbb/platform.c \
libbb/appletlib.c \
libbb/getopt32.c \
libbb/error.retval.c \
libbb/endofname.c \
libbb/signals.c \
libbb/skip.whitespc.c \
libbb/wfopen.c \
libbb/verror.msg.c \
libbb/bb.strtonum.c \
libbb/time.c \
libbb/printable.str.c \
libbb/full.write.c \
libbb/bb.qsort.c \
libbb/xrealloc.vec.c \
libbb/copyfd.c \
libbb/read.key.c \
libbb/unicode.c \
libbb/safe.write.c \
libbb/read.c \
libbb/s.gethostname.c \
libbb/get.line.c \
libbb/conc.pathfile.c \
libbb/last.char.is.c \
libbb/safe.poll.c \
libbb/escape.seq.c \
libbb/cmp.str.array.c \
libbb/llist.c \
libbb/parse.mode.c \
libbb/escape.seq.c \
libbb/messages.c \
libbb/appletlib.c \
libbb/bb.basename.c \
libbb/mempcpy.c \
libbb/vfork.and.run.c \
libbb/poll.c
OBJS = $(SRCS:.c=.o)
ROOTS = $(SRCS:.c=.root)
libbb/mempcpy.c
LIBBB_B_SRC = \
libbb/perror.msg.c \
libbb/signal.names.c \
libbb/ptrtoglobals.c \
libbb/safe.strncpy.c \
libbb/platform.c \
libbb/signals.c \
libbb/printable.str.c \
libbb/read.key.c \
libbb/safe.write.c \
libbb/read.c \
libbb/s.gethostname.c \
libbb/safe.poll.c \
libbb/parse.mode.c \
libbb/poll.c \
libbb/xfuncs.printf.c \
libbb/xfuncs.c \
libbb/xgetcwd.c \
libbb/xatonum.c \
libbb/xfunc.die.c \
libbb/skip.whitespc.c \
libbb/wfopen.c \
libbb/verror.msg.c \
libbb/time.c \
libbb/xrealloc.vec.c \
libbb/unicode.c \
libbb/vfork.and.run.c
SRCS = $(MAIN_SRC) $(SHELL_OTHER_SRC) $(COREUTILS_SRC) $(LIBBB_A_SRC) $(LIBBB_B_SRC)
OBJS = $(SRCS:.c=.a)
ROOT = $(MAIN_SRC:.c=.root)
INCLUDES = -I include -I shell -I libbb
DEFINES = -Dhush_main=main -DNDEBUG
OCC_FLAGS = -i -w -a0
# Hack to effectively disable close_on_exec_on method for now.
# This will cause us to leak file descriptors. TODO: Fix.
DEFINES += -DF_SETFD=-1 -DFD_CLOEXEC=-1
# For correct handling of varargs methods and fork, we need
# optimize bit 3 set (no stack repair code).
# Optimize bit 6 breaks some standard-compliant varargs code,
# and bits 0, 4, and 5 have known bugs. Disable for now.
OCC_FLAGS = -i -w -a0 -O8
STACKSIZE = 20480
# Add $(OCC_FLAGS) to CFLAGS on dmake
CFLAGS = $(null, $(OCC_FLAGS))
@ -68,9 +90,14 @@ PROG = hush
$(PROG): $(OBJS)
$(CC) $(OBJS) -o $@
%.o: %.c
$(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@
%.a: %.c
$(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@ \
$(eq,$<,$(MAIN_SRC) -s$(STACKSIZE) -r) \
$(!eq,$(SHELL_OTHER_SRC:s/$<//),$(SHELL_OTHER_SRC) -SSHELLOTHER) \
$(!eq,$(COREUTILS_SRC:s/$<//),$(COREUTILS_SRC) -SCOREUTILS_) \
$(!eq,$(LIBBB_A_SRC:s/$<//),$(LIBBB_A_SRC) -SLIBBB_A___) \
$(!eq,$(LIBBB_B_SRC:s/$<//),$(LIBBB_B_SRC) -SLIBBB_B___)
.PHONY: clean
clean:
$(RM) $(OBJS) $(ROOTS) $(PROG)
$(RM) $(OBJS) $(ROOT) $(PROG)

75
Makefile.gmake Normal file
View File

@ -0,0 +1,75 @@
SRCS = \
shell/hush.c \
shell/match.c \
shell/math.c \
shell/random.c \
shell/shell.common.c \
shell/glob.c \
coreutils/echo.c \
coreutils/test.c \
coreutils/test.ptr.hack.c \
libbb/xfuncs.printf.c \
libbb/xfuncs.c \
libbb/xgetcwd.c \
libbb/getopt32.c \
libbb/perror.msg.c \
libbb/xatonum.c \
libbb/signal.names.c \
libbb/ptrtoglobals.c \
libbb/error.retval.c \
libbb/xfunc.die.c \
libbb/safe.strncpy.c \
libbb/lineedit.c \
libbb/lineedptrhack.c \
libbb/platform.c \
libbb/endofname.c \
libbb/signals.c \
libbb/skip.whitespc.c \
libbb/wfopen.c \
libbb/verror.msg.c \
libbb/bb.strtonum.c \
libbb/time.c \
libbb/printable.str.c \
libbb/full.write.c \
libbb/bb.qsort.c \
libbb/xrealloc.vec.c \
libbb/copyfd.c \
libbb/read.key.c \
libbb/unicode.c \
libbb/safe.write.c \
libbb/read.c \
libbb/s.gethostname.c \
libbb/get.line.c \
libbb/conc.pathfile.c \
libbb/last.char.is.c \
libbb/safe.poll.c \
libbb/escape.seq.c \
libbb/cmp.str.array.c \
libbb/llist.c \
libbb/parse.mode.c \
libbb/messages.c \
libbb/appletlib.c \
libbb/bb.basename.c \
libbb/mempcpy.c \
libbb/vfork.and.run.c \
libbb/poll.c
OBJS = $(SRCS:.c=.o)
INCLUDES = -I include -I shell -I libbb
DEFINES = -Dhush_main=main -DNDEBUG
OCC_FLAGS = -i -w -a0
# Add $(OCC_FLAGS) to CFLAGS on dmake
CFLAGS = $(null, $(OCC_FLAGS))
PROG = hush
$(PROG): $(OBJS)
$(CC) $(OBJS) -o $@
%.o: %.c
$(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) $(OBJS) $(PROG)

View File

@ -1,4 +1,4 @@
#!/bin/sh
# Make with appropriate flags for gcc or clang on modern *nix systems
make CFLAGS="-std=c89 -funsigned-char -Wall -Wno-format-security -Wno-comment"
make -f Makefile.gmake CFLAGS="-std=c89 -funsigned-char -Wall -Wno-format-security -Wno-comment"

View File

@ -1063,6 +1063,10 @@ static void real_debug_printf(const char *fmt, ...) {
# define DEBUG_CLEAN 0
#endif
#ifdef __ORCAC__
segment "HUSH_A____";
#endif
#if DEBUG_EXPAND
static void debug_print_strings(const char *prefix, char **vv)
{
@ -5628,6 +5632,10 @@ static char **expand_assignments(char **argv, int count)
}
#ifdef __ORCAC__
segment "HUSH_B____";
#endif
static void switch_off_special_sigs(unsigned mask)
{
unsigned sig = 0;