Porting old make file to Windows - makefile

I'm attempting to convert this make file to a Windows make file. I haven't done anything like this before, and need some help. I've done research but don't really understand the plethora of errors that I'm running into. Is there an easy way to port this? Is it possible? Could this be made cross platform for cmake? This is all new to me.
#FLAGS = -lm -L/usr/pub/lib -lefence -o
#CC = cc -O2 -fullwarn -TENV:large_GOT
#CC = cc -g -Wall
CC = gcc -O2 # at least for SunOS
#CC = cc -g
#CC = cc -O2 -fullwarn
#CC = cc -O2
FLAGS = -lm -o
SOURCE = stride.c splitstr.c rdpdb.c initchn.c geometry.c thr2one.c one2thr.c filename.c tolostr.c strutil.c place_h.c hbenergy.c memory.c helix.c sheet.c rdmap.c phipsi.c command.c molscr.c die.c hydrbond.c mergepat.c fillasn.c escape.c p_jrnl.c p_rem.c p_atom.c p_helix.c p_sheet.c p_turn.c p_ssbond.c p_expdta.c p_model.c p_compnd.c report.c nsc.c area.c ssbond.c chk_res.c chk_atom.c turn.c pdbasn.c dssp.c outseq.c chkchain.c elem.c measure.c asngener.c p_endmdl.c stred.c contact_order.c contact_map.c
OBJECT = ${SOURCE:.c=.o}
BINDIR = .
.c.o:
$(CC) -c $< -o $#
stride : $(OBJECT)
$(CC) $(OBJECT) $(FLAGS) $(BINDIR)/stride${ARCH}
$(OBJECT) : stride.h protot.h
clean:
rm -f $(OBJECT)
show:
echo $(SOURCE)

Related

Using different compilers or compiler flags for different source files in the same object

I'm fairly new to makefiles and am currently running with the following one that came with the code and that I extended by the options FFLAGS_EXT1, COMP_EXT1, and file1.F90 and file2.F90:
FC = gfortran
FFLAGS = -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
FFLAGS_EXT1 = -g -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5 -Dno_nans -I ../ # Stricter compiler flags
LDFLAGS =
OBJ_EXT = o
EXE_EXT = x
COMP = $(FC) $(FFLAGS) -c -o $# $<
COMP_EXT1 = $(FC) $(FFLAGS_EXT1) -c -o $# $<
LINK = $(FC) $(LDFLAGS) -o $# $^
MAIN_MODULES = $(a list of file names without extensions)
OUR_MODULES = $(another list of file names without extensions)
# FORTRAN settings
.SUFFIXES: .F90 .$(OBJ_EXT)
# compilation rules
.F90.$(OBJ_EXT):
# $(COMP)
$(COMP_EXT1)
.PHONY: all
all: \
program1.$(EXE_EXT) program2.$(EXE_EXT) ...
program1.$(EXE_EXT): \
$(addsuffix .$(OBJ_EXT),$(MAIN_MODULES)) \
$(addsuffix .$(OBJ_EXT),$(OUR_MODULES)) \
file1.$(OBJ_EXT) \
file2.$(OBJ_EXT)
$(LINK)
...
This enables me to compile either all of the source files with FFLAGS or with the stricter FFLAGS_EXT1 depending on the choice of the compilation rule.
What I'd like to get is: use COMP as default (there are also other programs apart from the defined program1 which I must not break compatibility with) but use COMP_EXT1 or respectively FFLAGS_EXT1 specifically for file1 and file2 (the legacy code throws a lot of warnings I'd like to ignore and only focus on my new stuff - it is a fairly large project in total...).
I am aware of, e.g., this post, but I'm totally unaware of how to implement this in my case.
Any help would be highly appreciated!
EDIT:
Thanks to the hint by #Matt, I figured out the this changed version would do the trick:
FC = gfortran
FFLAGS = -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
FFLAGS_EXT1 = -g -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5 -Dno_nans -I ../ # Stricter compiler flags
LDFLAGS =
OBJ_EXT = o
EXE_EXT = x
COMP = $(FC) $(FFLAGS) -c -o $# $<
LINK = $(FC) $(LDFLAGS) -o $# $^
MAIN_MODULES = $(a list of file names without extensions)
OUR_MODULES = $(another list of file names without extensions)
# FORTRAN settings
.SUFFIXES: .F90 .$(OBJ_EXT)
# compilation rules
.F90.$(OBJ_EXT):
$(COMP)
file1.$(OBJ_EXT):
$(FC) $(FFLAGS_EXT1) -c file1.F90 -o file1.$(OBJ_EXT)
file2.$(OBJ_EXT):
$(FC) $(FFLAGS_EXT1) -c file2.F90 -o file2.$(OBJ_EXT)
.PHONY: all
all: \
program1.$(EXE_EXT) program2.$(EXE_EXT) ...
program1.$(EXE_EXT): \
$(addsuffix .$(OBJ_EXT),$(MAIN_MODULES)) \
$(addsuffix .$(OBJ_EXT),$(OUR_MODULES)) \
file1.$(OBJ_EXT) \
file2.$(OBJ_EXT)
$(LINK)
...
However, this seems to be quite cumbersome once there are many rules and many files. Simply using something like $(COMP_EXT1) did not work, as it failed with a no input file error.
Is there a way to shorten this construct?
Well, by all means, this is a matter of style. But let's try something:
# prefer simple variables over recursive ones...
FC := gfortran
FFLAGS := -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
FFLAGS_EXTRA := -fbacktrace -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5
# ...unless we *do* require deferred expansion
COMP = $(FC) $(FFLAGS) $(FFLAGS_$#) -c -o $# $<
LINK = $(FC) $(LDFLAGS) -o $# $^
# this is a matter of choice but one-letter variables could be handy
O := o
X := x
# I assume both file1 and file2 are already mentioned here
MAIN_MODULES := $(a list of file names without extensions)
OUR_MODULES := $(another list of file names without extensions)
# use computed variables for maximum flexibility
FFLAGS_file1.$O := $(FFLAGS_EXTRA)
FFLAGS_file2.$O := $(FFLAGS_EXTRA)
.PHONY: all
all: program1.$X program2.$X ...
program1.$X: $(addsuffix .$O,$(MAIN_MODULES) $(OUR_MODULES))
$(LINK)
program2.$X: ...
$(LINK)
# it is recommended to use pattern rules instead of suffix rules
%.$O: %.F90
$(COMP)
...
Maybe you want to go a different route, namely to use gmtt which is a library for well, quite some things programming in GNUmake. It offers a table data structure which is aimed at build config tasks like yours:
include gmtt-master/gmtt.mk
FC = gfortran
FFLAGS = -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
LDFLAGS =
OBJ_EXT = o
EXE_EXT = x
COMP = $(FC) $(FFLAGS) -c -o $# $<
LINK = $(FC) $(LDFLAGS) -o $# $^
MAIN_MODULES = $(a list of file names without extensions)
OUR_MODULES = $(another list of file names without extensions)
# FORTRAN settings
.SUFFIXES: .F90 .$(OBJ_EXT)
# Construct a gmtt table. The one caveat is that we must escape the space characters in the
# second column until we select entries from the table.
define COMPILE_FLAGS_TBL
2
file1.$(OBJ_EXT) $(call spc-mask,-fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5)
file2.$(OBJ_EXT) $(call spc-mask,-fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5)
endef
# Special flags: "select column 2 from COMPILE_FLAGS_TBL where first column is string-equal to the target"
# ...and recover the space characters afterwards:
FFLAGS_SPECIAL = $(call spc-unmask,$(call select,2,$(COMPILE_FLAGS_TBL),$$(call str-eq,$$1,$#)))
# compilation rules
.PHONY: all
all: foo.o bar.o file1.o file2.o
%.F90:
touch $#
%.o: %.F90
#echo flags: $(FFLAGS) $(FFLAGS_SPECIAL)
Output:
$ make
touch foo.F90
flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
touch bar.F90
flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
touch file1.F90
flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5
touch file2.F90
flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5
rm bar.F90 file1.F90 foo.F90 file2.F90
You can have more flexible file selection by using globs:
include gmtt-master/gmtt-master/gmtt.mk
FFLAGS = -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
OBJ_EXT = o
# Construct a gmtt table. The one caveat is that we must escape the space characters in the
# second column until we select entries from the table.
define COMPILE_FLAGS_TBL
2
file1.$(OBJ_EXT) $(call spc-mask,-fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5)
file2.$(OBJ_EXT) $(call spc-mask,-fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5)
endef
define PATTERN_FLAGS_TBL
2
*_frobozz_[7-9].$(OBJ_EXT) $(call spc-mask,-ffrobozz)
X_frabazz_*.$(OBJ_EXT) $(call spc-mask,-ffrabazz -dwhatever)
endef
# Special flags: "select column 2 from COMPILE_FLAGS_TBL where first column is string-equal to the target"
# ...and recover the space characters afterwards:
FFLAGS_SPECIAL = $(call spc-unmask,$(call select,2,$(COMPILE_FLAGS_TBL),$$(call str-eq,$$1,$#)))
# Very special flags: "select column 2 from PATTERN_FLAGS_TBL where target matches glob in first column"
# ...and recover the space characters afterwards
FFLAGS_VERY_SPECIAL = $(call spc-unmask,$(call select,2,$(PATTERN_FLAGS_TBL),$$(call glob-match,$#,$$1)))
# compilation rules
.PHONY: all
all: foo.o bar.o file1.o file2.o A_frobozz_8.o A_frobozz_6.o X_frabazz_mike.o X_frabazz_mandy.o
%.F90:
#touch $#
%.o: %.F90
#echo $# flags: $(FFLAGS) $(FFLAGS_SPECIAL) $(FFLAGS_VERY_SPECIAL)
Output:
$ make
foo.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
bar.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
file1.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5
file2.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -fbacktrace -ffpe-trap=zero,invalid,overflow,underflow -fbounds-check -fcheck=all -Wconversion -std=gnu -O3 -fmax-errors=5
A_frobozz_8.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -ffrobozz
A_frobozz_6.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../
X_frabazz_mike.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -ffrabazz -dwhatever
X_frabazz_mandy.o flags: -g -ffpe-trap=zero,invalid,overflow,underflow -Dno_nans -I ../ -ffrabazz -dwhatever
rm X_frabazz_mandy.F90 A_frobozz_8.F90 bar.F90 file1.F90 foo.F90 A_frobozz_6.F90 file2.F90 X_frabazz_mike.F90

modifying Makefile for silverfrost FTN95 ( Windows)

Compiling error
I am quite new to Fortran coding.
Currently, I have a makefile which has been previously used by original authors to compile the Fortran codes in Linux. However, I cannot understand what needs to be changed in the previous makefile to run it in Windows-based compiler Silverfrost FTN95.
While trying to compile in FTN95 I encountered the following error:
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>MAKE TPX
mpif90 -w -O3 -w -O3 -c ssizgrd.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c ssizgrd.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `ssizgrd.o' failed
MAKE: *** [ssizgrd.o] Error 2
C:\Users\Geo-TGS\Documents\landslidemodel\src\TRIGRS>make trg
mpif90 -w -O3 -w -O3 -c grids.f95
process_begin: CreateProcess(NULL, mpif90 -w -O3 -w -O3 -c grids.f95, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:59: recipe for target `grids.o' failed
make: *** [grids.o] Error 2
Below is the Makefile code:
TRG = trg
PRG = prg
TPX = tpx
OBJT90 = trigrs.o flux.o prpijz.o svxmdv.o svijz.o dzero_brac.o
OBJT95 = grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o satfin.o savage.o steady.o trini.o unsinf.o ivestp.o pstpf.o rnoff.o satinf.o smallt.o svgstp.o unsfin.o unsth.o ssizgrd.o svlist.o
OBJT77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o isvgrd.o roots.o srdgrd.o srdswm.o ssvgrd.o
OBJP90 = trigrs_p.o partial_p.o flux.o flux_p.o prpijz.o svxmdv.o svijz.o dzero_brac.o srdgrd_p.o irdgrd_p.o
OBJP95 = modules_p.o grids.o input_vars.o model_vars.o dsimps.o input_file_defs.o iverson.o pstpi.o pstpi_p.o satfin.o satfin_p.o savage.o steady.o trini.o trini_p.o unsinf.o unsinf_p.o ivestp.o ivestp_p.o pstpf.o pstpf_p.o rnoff.o satinf.o satinf_p.o smallt.o svgstp.o svgstp_p.o unsfin.o unsfin_p.o unsth.o unsth_p.o ssizgrd.o ssizgrd_p.o svlist.o rnoff_p.o steady_p.o
OBJP77 = calerf.o dbsct.o derfc.o irdgrd.o irdswm.o irdswm_p.o isvgrd.o roots.o srdgrd.o srdswm.o srdswm_p.o ssvgrd.o
OBJX90 = tpindx.o nxtcel.o
OBJX95 = ssizgrd.o
OBJX77 = isvgrd.o mpfldr.o rdflodir.o sindex.o slofac.o srdgrd1.o
LIBS =
CC = gcc -O3
CCFLAGS = -lgsl -lgslcblas -lm
FC = ftn95 -w -O3
FFLAGS =
F90 = f95 -w -O3
MPIF90 = mpif90 -w -O3
F90FLAGS = -w -O3
LDFLAGS = -w -O3
all: $(TRG) $(PRG)
#-----------------------------------------------------------------
$(TRG): $(OBJT95) $(OBJT90) $(OBJT77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJT95) $(OBJT90) $(OBJT77) $(CCFLAGS) $(LIBS)
$(PRG): $(OBJP95) $(OBJP90) $(OBJP77)
$(MPIF90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJP95) $(OBJP90) $(OBJP77)
$(CCFLAGS) $(LIBS)
$(TPX): $(OBJX95) $(OBJX90) $(OBJX77)
$(F90) $(CCLIBS) $(LDFLAGS) -o $# $(OBJX95) $(OBJX90) $(OBJX77) $(CCFLAGS) $(LIBS)
#-----------------------------------------------------------------
clean:
rm -f $(TRG) $(TPX) $(PRG)
rm -rf $(OBJT95) $(OBJT90) $(OBJT77) $(OBJP95) $(OBJP90) $(OBJP77)
rm -rf $(OBJX95) $(OBJX90) $(OBJX77)
rm -rf *.mod *.exe *.stackdump
.SUFFIXES: $(SUFFIXES) .f90 .f .c .f95
.f90.o:
$(MPIF90) $(F90FLAGS) -c $<
.f.o:
$(MPIF90) $(F90FLAGS) -c $<
.c.o:
$(CC) $(CCINCLUDE) -c -w $<
.f95.o:
$(MPIF90) $(F90FLAGS) -c $<
What changes need to be made for the code to compile?

Makefile: object file not found

I have the following Makefile. Whenever I run make, I get the following error.
ifort: error #10236: File not found: 'mkl_matrix_multiply.o'
I have been trying to figure this out for a while now with no luck.
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe
Any help would be greatly appreciated.
Seems like you are missing -c in mkl_matrix_multiply.o rule.
Modify your makefile as
C = icc
FC = ifort
LD = ifort
OPT = -Ofast -vec_report6 -simd -xhost -debug -traceback -ftrapuv
OP = -Ofast -vec_report6 -simd -xhost
LINK = -L$(MKLROOT)/lib/intel64 $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
INCLUDE = -openmp -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include
mkl_matrix_multiply.exe: mkl_matrix_multiply.o timing.o
$(LD) -o mkl_matrix_multiply.exe mkl_matrix_multiply.o timing.o
mkl_matrix_multiply.o: mkl_matrix_multiply.f90
$(FC) -c $(INCLUDE) $(LINK) mkl_matrix_multiply.f90
timing.o: timing.c
$(CC) $(OP) -c timing.c
dummy.o: dummy.c
$(CC) $(OP) -c dummy.c
clean:
rm -f *.o matrix_multiply.exe

Ruby-generated makefile doesn't run

Maybe this is a really obvious answer, but I'm trying to extend Ruby using C in a Windows environment and I can't make the extension when I run mingw32-make it gets as far as generating a file called "forktest-i386-mingw32.def" and then says "No rule to make target 'ruby.h', needed by 'forktest.o'".
Forktest is the name of the extension that I'm trying to make.
The makefile was generated by ruby's own create_makefile command and it's really convoluted so I can't make heads or tales of it, but here it is anyway:
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
Q1 = $(V:1=)
Q = $(Q1:0=#)
n=$(NULLCMD)
ECHO1 = $(V:1=#$n)
ECHO = $(ECHO1:0=#echo)
#### Start of system configuration section. ####
srcdir = .
topdir = /D/Programs/Ruby193/include/ruby-1.9.1
hdrdir = /D/Programs/Ruby193/include/ruby-1.9.1
arch_hdrdir = D:/Programs/Ruby193/include/ruby-1.9.1/$(arch)
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
DESTDIR = D:
prefix = $(DESTDIR)/Programs/Ruby193
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
exec_prefix = $(prefix)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
vendordir = $(rubylibprefix)/vendor_ruby
sitedir = $(rubylibprefix)/site_ruby
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(datarootdir)/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(prefix)/include
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
rubylibdir = $(rubylibprefix)/$(ruby_version)
archdir = $(rubylibdir)/$(arch)
sitelibdir = $(sitedir)/$(ruby_version)
sitearchdir = $(sitelibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendorarchdir = $(vendorlibdir)/$(sitearch)
NULLCMD = :
CC = gcc
CXX = g++
LIBRUBY = lib$(RUBY_SO_NAME).dll.a
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
OUTFLAG = -o
COUTFLAG = -o
RUBY_EXTCONF_H =
cflags = $(optflags) $(debugflags) $(warnflags)
optflags = -O3
debugflags = -g
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
CFLAGS = $(cflags)
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
DEFS =
CPPFLAGS = $(DEFS) $(cppflags)
CXXFLAGS = $(CFLAGS) $(cxxflags)
ldflags = -L.
dldflags = -Wl,--enable-auto-image-base,--enable-auto-import $(DEFFILE)
ARCH_FLAG =
DLDFLAGS = $(ldflags) $(dldflags)
LDSHARED = $(CC) -shared $(if $(filter-out -g -g0,$(debugflags)),,-s)
LDSHAREDXX = $(CXX) -shared $(if $(filter-out -g -g0,$(debugflags)),,-s)
AR = ar
EXEEXT = .exe
RUBY_BASE_NAME = ruby
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = msvcrt-ruby191
arch = i386-mingw32
sitearch = i386-msvcrt
ruby_version = 1.9.1
ruby = D:/Programs/Ruby193/bin/ruby
RUBY = $(ruby)
RM = rm -f
RM_RF = $(RUBY) -run -e rm -- -rf
RMDIRS = rmdir --ignore-fail-on-non-empty -p
MAKEDIRS = /usr/bin/mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
#### End of system configuration section. ####
preload =
libpath = . $(libdir)
LIBPATH = -L. -L$(libdir)
DEFFILE = $(TARGET)-$(arch).def
CLEANFILES = mkmf.log $(DEFFILE)
DISTCLEANFILES =
DISTCLEANDIRS =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32 -limagehlp
SRCS = forktest.c ruby.c
OBJS = forktest.o ruby.o
TARGET = forktest
DLLIB = $(TARGET).so
EXTSTATIC =
STATIC_LIB =
BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).so
CLEANOBJS = *.o *.bak
all: $(DLLIB)
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-rb
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-rb-default clean-rb
#-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
distclean-rb-default::
distclean-rb::
distclean-so::
distclean: clean distclean-so distclean-rb-default distclean-rb
#-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
#-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
#-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
realclean: distclean
install: install-so install-rb
install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
#-$(MAKEDIRS) $(#D)
$(INSTALL_PROG) $(DLLIB) $(#D)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
pre-install-rb-default:
$(ECHO) installing default forktest libraries
$(RUBYARCHDIR):
$(Q) $(MAKEDIRS) $#
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o
.cc.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.mm.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.cxx.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.cpp.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$# -c $<
.c.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$# -c $<
.m.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$# -c $<
$(DLLIB): $(DEFFILE) $(OBJS) Makefile
$(ECHO) linking shared-object $(DLLIB)
#-$(RM) $(#)
$(Q) $(LDSHARED) -o $# $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
$(DEFFILE):
$(ECHO) generating $(#)
$(Q) $(RUBY) -e "puts 'EXPORTS', '' + 'Init_$(TARGET)'.sub(/\..*\z/,'')" > $#
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
I had the same issue and found that I accidentally had the MinGW Make on my path. This meant Ruby DevKit found that version before it's own msys version.
The mingw version doesn't handle the /D/Programs/Ruby193/ style of paths and produced the "No rule to make target 'ruby.h'..." error.
My solution was to remove MinGW make from my PATH so that Ruby DevKit found the msys version of Make when it runs (when it prints "Temporarily enhancing PATH to include DevKit...").
I checked my version of Make from the msys.bat environment (just run C:\devkit\msys.bat):
$ which make
# Should print a location like: C:\devkit\bin\make.exe
And check the version like this:
$ make --version
The correct msys version included this in the last line:
This program built for i686-pc-msys
The incorrect MinGW version output this:
GNU Make 4.1
Built for i686-w64-mingw32
I'm using ruby 2.2.3p173 and DevKit-mingw64-32-4.7.2-20130224-1151-sfx but this seems to be a PATH issue, not a ruby issue.

understanding Makefiles

I have the following make file:
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2 -W -Wall -Wno-unused -Wno-multichar
COMPONENTHEADER = Q_OBJECT
CPP = gcc -E
CPPFLAGS = -I/usr/include/Inventor/annex -D_REENTRANT -I/usr/share/qt3/include
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -g -O2 -fno-exceptions -W -Wall -Wno-unused -Wno-multichar -Woverloaded- virtual
CYGPATH_W = echo
GUI = QT
Gui = Qt
INCLUDES =
LIBS = -lSoQt -lqt-mt -lXmu -lXi -lCoin -lGL -lXext -lSM -lICE -lX11 -ldl -lpthread -lm -lcxcore -lcv -lhighgui -lcvaux
OBJS = MathTools.o PointCloud.o ExtractFeatures.o Tile.o Shape.o RoadDynamic.o
SRCS = MathTools.cpp PointCloud.cpp ExtractFeatures.cpp Tile.cpp Shape.cpp RoadDynamic.cpp main.cpp
HDRS = constants.h Shape.h MathTools.h PointCloud.h ExtractFeatures.h Tile.h RoadDynamic.h
WIDGET = QWidget *
all: main
main: main.o ${OBJS}
${CC} ${CFLAGS} ${INCLUDES} -o $# main.o ${OBJS} ${LIBS}
.c.o:
${CC} ${CFLAGS} ${INCLUDES} -c $<
depend:
makedepend ${SRCS}
clean:
rm *.o core *~
tar:
tar cf code.tar Makefile *.c *.h testfile1
print:
more Makefile $(HDRS) $(SRCS) | enscript -2r -p listing.ps
I am wondering why when I run make the output is
g++ -g -O2 -fno-exceptions -W -Wall -Wno-unused -Wno-multichar -Woverloaded-virtual -I/usr/include/Inventor/annex -D_REENTRANT -I/usr/share/qt4/include -c -o main.o main.cpp
instead of:
gcc -g -O2 -W -Wall -Wno-unused -Wno-multichar ...
it seems the cxx variables are overriding the cc variables. Why is that?
also what does the "include =" do in this case? It doesn't seem to be set to anything.
Thank you
Because your object files are apparently built from .cpp files. You have no explicit rule for building .o files from .cpp files, so Make uses the implicit rule $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c.

Resources