~nloomans/ft_select

204227a12fb616f8e6a8874db1d7b233d3c86aba — Noah Loomans 1 year, 8 months ago a4ef762
add normify script
3 files changed, 128 insertions(+), 1 deletions(-)

A normify
A normify.mk
M subprojects/libft
A normify => normify +42 -0
@@ 0,0 1,42 @@
#!/usr/bin/env python3
import os
import sys
import shutil
from glob import glob

os.chdir(sys.path[0])

shutil.rmtree("normified", ignore_errors=True)
os.mkdir("normified")
shutil.copytree("src", "normified/src")
for spec_file in glob("normified/src/*_test.c"):
  os.remove(spec_file)
shutil.copytree("inc", "normified/inc")

os.system("echo $USER > normified/author")
shutil.copy("normify.mk", "normified/Makefile")

os.system("subprojects/libft/normify")
shutil.move("subprojects/libft/normified", "normified/libft")
os.system("subprojects/libftprintf/normify")
shutil.move("subprojects/libftprintf/normified", "normified/libftprintf")

os.chdir("normified")

with open('Makefile', 'r') as fd:
  makefile = fd.read()

src_files = glob("src/**/*.c", recursive=True)
src_files.remove('src/render.c')
src_files.remove('src/render.debug.c')

makefile = makefile.replace(
    "%SRC_DIR%",
    " \\\n".join(src_files))

makefile = makefile.replace(
    "%INC_DIR%",
    " \\\n".join(glob("inc/**/*.h", recursive=True)))

with open('Makefile', 'w') as fd:
  fd.write(makefile)

A normify.mk => normify.mk +85 -0
@@ 0,0 1,85 @@
# **************************************************************************** #
#                                                                              #
#                                                         ::::::::             #
#    ft_select                                          :+:    :+:             #
#                                                      +:+                     #
#    By: Noah Loomans                                 +#+                      #
#        <nloomans@student.codam.nl>                 +#+                       #
#                                                   #+#    #+#                 #
#    License: GPLv3                                ########   odam.nl          #
#                                                                              #
# **************************************************************************** #

NAME=ft_select

all: $(NAME)

# Libaries #--------------------------------------------------------------------

LIBFT_NAME=		ft
LIBFT_DIR=		libft
LIBFT_A=		$(LIBFT_DIR)/lib$(LIBFT_NAME).a
LIBFT_IFLAGS=	-I $(LIBFT_DIR)
LIBFT_LFLAGS=	-L $(LIBFT_DIR) -l$(LIBFT_NAME)

$(LIBFT_A):
	$(MAKE) -C $(LIBFT_DIR)

FTPRINTF_NAME=		ftprintf
FTPRINTF_DIR=		libftprintf
FTPRINTF_A=			$(FTPRINTF_DIR)/lib$(FTPRINTF_NAME).a
FTPRINTF_IFLAGS=	-I $(FTPRINTF_DIR)
FTPRINTF_LFLAGS=	-L $(FTPRINTF_DIR) -l$(FTPRINTF_NAME) -ltermcap

$(FTPRINTF_A):
	$(MAKE) -C $(FTPRINTF_DIR)

# Definitions #-----------------------------------------------------------------

SRC_DIR=		src
INC_DIR=		inc
OBJ_DIR=		obj

SRC_FILES=		%SRC_DIR%
INC_FILES=		%INC_DIR%
OBJ_FILES=		$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))

ifeq ($(RENDER),debug)
SRC_FILES+=		src/render.debug.c
else
SRC_FILES+=		src/render.c
endif

CFLAGS=			-Werror -Wall -Wextra -O2 -g
IFLAGS=			-I $(INC_DIR) $(LIBFT_IFLAGS) $(FTPRINTF_IFLAGS)
LFLAGS=			$(LIBFT_LFLAGS) $(FTPRINTF_LFLAGS)

# Regular rules #---------------------------------------------------------------

$(NAME): $(OBJ_FILES) $(LIBFT_A) $(FTPRINTF_A)
	$(CC) -o $@ $(OBJ_FILES) $(CFLAGS) $(LFLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_FILES)
	@mkdir -p $$(dirname $@)
	$(CC) -o $@ -c $< $(CFLAGS) $(IFLAGS)

# Phonies #---------------------------------------------------------------------

clean:
	@$(MAKE) -C $(LIBFT_DIR) fclean
	@$(MAKE) -C $(FTPRINTF_DIR) fclean
	@rm -rf $(OBJ_DIR)

fclean: clean
	@$(MAKE) -C $(LIBFT_DIR) fclean
	@$(MAKE) -C $(FTPRINTF_DIR) fclean
	@rm -f $(NAME)

re:
	@$(MAKE) fclean
	@$(MAKE)

# Special #---------------------------------------------------------------------

.SECONDARY: $(OBJ_FILES)
.PHONY: all clean fclean re

M subprojects/libft => subprojects/libft +1 -1
@@ 1,1 1,1 @@
Subproject commit cd52fd2cc2c4efb99a159f9eb758827430b91a1c
Subproject commit 76156a8eba7fac8c404ec9bcbb370b7ee9fd8a56