Skip to content

Commit 8494098

Browse files
committed
Better cpp gestion
1 parent 8d5fca9 commit 8494098

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

genmake/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# **************************************************************************** #
1414

1515
PROG="genmake"
16-
VERSION="v1.0"
16+
VERSION="v1.1"
1717
DESC="Generate Makefile for C Project of 42 School"
1818

1919
BUILDER=dict()

genmake/makefile.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ def generate_makefile(params: dict) -> str:
2424
config.BUILDER["bin_dir"] = params["bin_folder"]
2525
if params["lang_c"] == False:
2626
config.BUILDER["src_file_ext"] = "cpp"
27-
config.BUILDER["compil_mac"] = "g++"
28-
config.BUILDER["compil_linux"] = "clang++"
27+
config.BUILDER["compile_rule"] = "CXX"
2928
else:
3029
config.BUILDER["src_file_ext"] = "c"
31-
config.BUILDER["compil_mac"] = "gcc"
32-
config.BUILDER["compil_linux"] = "clang"
30+
config.BUILDER["compile_rule"] = "CC"
3331
config.BUILDER["lib"] = build_rules.lib_inc(params)
3432
config.BUILDER["all_rules"] = build_rules.all(params)
3533
config.BUILDER["bonus_rules"] = build_rules.bonus(params)
@@ -44,9 +42,11 @@ def generate_makefile(params: dict) -> str:
4442
# genmake {version}
4543
4644
#Compiler and Linker
47-
CC := {compil_linux}
45+
CC := clang
46+
CXX := c++
4847
ifeq ($(shell uname -s),Darwin)
49-
CC := {compil_mac}
48+
CC := gcc
49+
CXX := g++
5050
endif
5151
5252
#The Target Binary Program
@@ -74,7 +74,7 @@ def generate_makefile(params: dict) -> str:
7474
cflags.valgrind := -Wall -Werror -Wextra -DDEBUG -ggdb
7575
cflags.debug := -Wall -Werror -Wextra -DDEBUG -ggdb -fsanitize=address -fno-omit-frame-pointer
7676
CFLAGS := $(cflags.$(BUILD))
77-
CPPFLAGS := $(cflags.$(BUILD))
77+
CPPFLAGS := $(cflags.$(BUILD)) -std=c++98
7878
7979
lib.release := {lib}
8080
lib.valgrind := $(lib.release)
@@ -135,12 +135,12 @@ def generate_makefile(params: dict) -> str:
135135
# Link
136136
$(TARGETDIR)/$(TARGET): $(OBJECTS)
137137
@mkdir -p $(TARGETDIR)
138-
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
138+
$({compile_rule}) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
139139
140140
# Link Bonus
141141
$(TARGETDIR)/$(TARGET_BONUS): $(OBJECTS_BONUS)
142142
@mkdir -p $(TARGETDIR)
143-
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
143+
$({compile_rule}) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
144144
145145
$(BUILDIR):
146146
@mkdir -p $@
@@ -149,8 +149,8 @@ def generate_makefile(params: dict) -> str:
149149
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
150150
@mkdir -p $(dir $@)
151151
@$(ECHO) "$(TARGET)\\t\\t[$(C_PENDING)⏳$(C_RESET)]"
152-
$(CC) $(CFLAGS) $(CPPFLAGS) $(INC) -c -o $@ $<
153-
@$(CC) $(CFLAGS) $(CPPFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
152+
$({compile_rule}) $(CFLAGS) $(CPPFLAGS) $(INC) -c -o $@ $<
153+
@$({compile_rule}) $(CFLAGS) $(CPPFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
154154
@$(ERASE)
155155
@$(ERASE)
156156
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp

0 commit comments

Comments
 (0)