CC = g++
PROF = -O -g
C_FLAGS = -Wall -Wno-char-subscripts $(PROF)
L_FLAGS = $(PROF)
EXE_NAME = rof
CORE_OBJ = core/accounts.o core/cmd.o core/cmd_comm.o core/cmd_olc.o core/cmd_olcarea.o \
core/cmd_olcnpc.o core/cmd_olcobj.o core/cmd_olcroom.o core/cmd_staff.o \
core/comm.o core/interp.o core/login.o core/lookup.o core/magic.o \
core/skills.o core/spells.o core/tables.o core/utils.o
CLASSES_OBJ = classes/AREA_DATA.o classes/CHAR_DATA.o classes/MEMORY_HANDLER.o \
classes/MOB_INDEX_DATA.o classes/OBJ_DATA.o classes/OBJ_INDEX_DATA.o \
classes/ROOM_INDEX_DATA.o classes/WORLD_DATA.o \
O_FILES = $(CORE_OBJ) $(CLASSES_OBJ)
$(EXE_NAME): $(O_FILES)
rm -f $(EXE_NAME)
$(CC) $(L_FLAGS) -o $(EXE_NAME) $(O_FILES)
.c.o: core.h
$(CC) -c $(C_FLAGS) $<
.c.o: core.h
obj/.c.o: core.h
.makefile
|
+—src
| +—classes
| +—core
+—obj
| +—classes
| +—core
+—bin
+—source
+—classes
+—core
+—obj
+—.rof
+—.makefile
GCC = gcc
RM = rm
EXE = ../bin/rom
C_FLAGS = -DSYSV -ggdb -w -DNOCRYPT
L_FLAGS = -ggdb -lcrypt -lm -w -DNOCRYPT
#Source Files.
SRC := $(wildcard *.c) $(wildcard clans/*.c)
#Object files.
OBJ_DIR = obj
OBJ := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC))
#Make rom
rom: $(OBJ)
$(GCC) $(L_FLAGS) -lcrypt -o $(EXE) $(OBJ)
$(OBJ_DIR)/%.o: %.c
$(GCC) $(C_FLAGS) -c -o $@ $<
clean:
$(RM) -f $(OBJ) $(EXE) *~ *.bak *.orig *.rej
CC = g++
PROF = -O -ggdb
C_FLAGS = -Wall -Wno-char-subscripts $(PROF)
EXE_NAME = rof
OBJ_DIR = obj
SRC := $(wildcard core/*.c) $(wildcard classes/*.c) $(wildcard mod_magic/*.c) $(wildcard mod_olc/*.c)
H_FILES := $(wildcard core/*.h) $(wildcard classes/*.h) $(wildcard mod_magic/*.h) $(wildcard mod_olc/*.h)
OBJ := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC))
# COLOR CODES
L_NRM = \e
CC = g++
PROF = -O -ggdb
C_FLAGS = -Wall -Wno-char-subscripts $(PROF)
EXE_NAME = rof
OBJ_DIR = obj
SRC := $(wildcard core/*.c) $(wildcard classes/*.c) $(wildcard mod_magic/*.c) $(wildcard mod_olc/*.c)
H_FILES := $(wildcard core/*.h) $(wildcard classes/*.h) $(wildcard mod_magic/*.h) $(wildcard mod_olc/*.h)
OBJ := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC))
# COLOR CODES
L_NRM = \e[0;00m
L_YELLOW = \e[1;33m
L_WHITE = \e[1;37m
L_CYAN = \e[1;36m
$(EXE_NAME): $(OBJ)
@rm -f $(EXE_NAME)
@$(CC) $(PROF) -o $(EXE_NAME) $(OBJ)
@echo -e "$(L_YELLOW)FILE $(EXE_NAME).exe COMPLETE $(L_NRM)"
$(OBJ_DIR)/%.o: %.cpp $(H_FILES)
@echo -e "$(L_WHITE)FILE: $(L_YELLOW)$<$(L_CYAN)"
@$(CC) $(C_FLAGS) -c -o $@ $<
clean:
@rm -f $(EXE_NAME) $(OBJ)
[/code]
Yup thats it. Finally figured it all out, i know what everything is doing and why now. I feel so much smarter. LOL.
So my source file directory for my base has become a bit more muddled then i like.
So i decided i want to separate the files up some into sub directories.
I however am unsure of how to get a Makefile to accompany this.
Ive done some research on the net, but i have to admit I'm not very familiar with Makefiles to begin with.
From what ive read the most common way to go about this is to have makefiles in each directory and have
the main makefile include them.
What i was wondering is.
1) Is there a existing base that also has its source split into multiple directories so i can look at it an see how they go about it?
2) Is there a way to do this from within one Makefile instead of one in each directory?
3) And does anyone have a really good resource for makefile for someone who is rather oblivious to them. Seems most tutorials and such i find assume some sort of basic understanding of things that im lacking.
Thanks.