본문 바로가기

UNIX_LINUX_C_C++

make예제

#
# makefile
#
CC = g++

TARGET = xtranscode
TARGET2 = prsmng
TARGET3 = mntmng

BINDIR = ../../bin
#BINDIR = .

LIBDIR = ../../lib

COMM = ../comm

#-L$(COMM) -lmygun
LIBS = \
-lnsl -lpthread

OFLAGS = -g -Wall -O6 -march=pentiumpro

EXTRA_FLAGS += -DDEBUG=1

#
# if unix add -lsocket
# if linux remove -lsocket
#

OFILES=\
xtrans.o \
comm.o

OFILES2=\
prsmng.o \
comm.o

OFILES3=\
mntmng.o \
comm.o

CFLAGS=\
$(EXTRA_FLAGS) \
$(OFIAGS) \
-I.

all: $(TARGET) $(TARGET2) $(TARGET3)

$(TARGET): $(OFILES)
$(CC) -o $(BINDIR)/$(TARGET) $(CFLAGS) $(OFILES) $(LIBS)

$(TARGET2): $(OFILES2)
$(CC) -o $(BINDIR)/$(TARGET2) $(CFLAGS) $(OFILES2) $(LIBS)

$(TARGET3): $(OFILES3)
$(CC) -o $(BINDIR)/$(TARGET3) $(CFLAGS) $(OFILES3) $(LIBS)

xtrans.o: xtrans.cpp
$(CC) -c xtrans.cpp $(CFLAGS)

comm.o: comm.cpp
$(CC) -c comm.cpp $(CFLAGS)

prsmng.o: prsmng.cpp
$(CC) -c prsmng.cpp $(CFLAGS)

mntmng.o: mntmng.cpp
$(CC) -c mntmng.cpp $(CFLAGS)

clean:
rm -f ./*.o
rm -f $(BINDIR)/$(TARGET)
rm -f $(BINDIR)/$(TARGET2)
rm -f $(BINDIR)/$(TARGET3)