Rev 3280 | Blame | Last modification | View Log | Download | RSS feed
# Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of the original program's authors nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
CC = gcc
CFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes
PROGRAM = bdsh
# Any directory that cleaning targets should know about
SUBDIRS = \
./ \
cmds/ \
cmds/modules/ \
cmds/modules/help/ \
cmds/modules/quit/ \
cmds/modules/rm/ \
cmds/modules/cat/ \
cmds/modules/touch/ \
cmds/modules/mkdir/ \
cmds/modules/ls/ \
cmds/builtins/ \
cmds/builtins/pwd/ \
cmds/builtins/cd/ \
lib/
# Commands
MODULES = \
cmds/modules/help/help.c \
cmds/modules/quit/quit.c \
cmds/modules/rm/rm.c \
cmds/modules/cat/cat.c \
cmds/modules/touch/touch.c \
cmds/modules/mkdir/mkdir.c \
cmds/modules/ls/ls.c
BUILTINS = \
cmds/builtins/pwd/pwd.c \
cmds/builtins/cd/cd.c
# Non-commands and command loaders
SOURCES = \
cmds/mod_cmds.c \
cmds/builtin_cmds.c \
errors.c \
input.c \
util.c \
exec.c \
scli.c
# Included Libs, stuff we build and include (not link against)
LIBS =
# Add included libs to include path
INC = -I. -Icmds/ -Icmds/builtins -Icmds/modules -Ilib -Ilib/ustr
# All your sources are belong to us, !!! Order Matters Here !!!
SRC = $(LIBS) $(MODULES) $(BUILTINS) $(SOURCES)
# Every .c file in $(SRC) will be built to file.o
OBJECTS = $(SRC:.c=.o)
# For easy cleaning, *.o is already handled
CLEANDIRS := $(addsuffix *~,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.out,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.d,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.map,$(SUBDIRS))
CLEANDIRS += $(addsuffix *.disasm,$(SUBDIRS) )
%.o: %.c
$(CC) $(CFLAGS) $(INC) -c $< -o $@
@$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d
$(PROGRAM): $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
# Everything else is a phony target
.PHONY: all clean distclean
all: $(PROGRAM)
clean:
@-rm -f $(OBJECTS)
@-rm -f $(PROGRAM)
@-rm -f $(CLEANDIRS)
distclean: clean
# Do not delete - header dependencies
-include $(OBJECTS:.o=.d)