build: improve build efficiency

This commit is contained in:
iridiumR 2022-09-18 21:48:23 +08:00
parent 4a018bad5d
commit 72b7a424b7
No known key found for this signature in database
GPG key ID: 5574BE4450D55618
2 changed files with 29 additions and 16 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
*.o
*.ro
*.do
ddish
dish

View file

@ -1,22 +1,32 @@
OBJ=main.o line.o loop.o exec.o builtin.o
CC=gcc
CFLAGS= -O3 -Wall
SHELL := /bin/bash
CC = gcc
SRC = main.c loop.c exec.c line.c builtin.c
OBJ = $(SRC:.c=.ro)
DBGOBJ = $(SRC:.c=.do)
EXE = dish
DBGEXE = ddish
all:release
r:release
release:dish
all:release debug
debug: CFLAGS = -g -O0 -DDEBUG
release: CFLAGS = -Wall -O3
dish: $(OBJ)
$(CC) $(CFLAGS) -o dish $(OBJ)
release: $(OBJ)
$(CC) $(CFLAGS) -o $(EXE) $(OBJ)
d:
make clean
make debug
debug: $(DBGOBJ)
$(CC) $(CFLAGS) -o $(DBGEXE) $(DBGOBJ)
debug: CFLAGS += -DDEBUG -g
debug: dish
c: clean
clean:
rm -f $(OBJ) dish
rm -f *.o
$(OBJ):$(SRC)
$(CC) $(CFLAGS) -c $(SRC)
rename .o .ro *.o
$(DBGOBJ):$(SRC)
$(CC) $(CFLAGS) -c $(SRC)
rename .o .do *.o
c:clean
d:debug
r:release