tags:

views:

98

answers:

6

I have a huge project, whole written in C language and I have a single make file that is used to compile it. The project C files contains lots of capitalize problems in it's header files, meaning there are tones of header files that were miss-spelled in lots of C files. The problem is I need to migrate this project to compile on Linux machine and since Linux is case sensitive I got tones of errors.

Is there an elegant way which I can run make file in Linux and tell him to ignore case sensitive? Any other solution will be welcome as well.

Thanks a lot. Motti.

+2  A: 

You can mount the files on a case-insensitive file system. FAT comes to mind. ntfs-3g does not appear to support this.

reinierpost
Nope. ntfs-3g on linux is case sensitive. You can easily create "File.txt" and "file.txt" and same folder, and you won't be able to access one of them on windows machine. http://www.tuxera.com/community/ntfs-3g-faq/#posixfilenames1
SigTerm
You're right - I misread the manpage. I just corrected this (so your comment seems odd now.) Thanks.
reinierpost
what ...?! I noticed it with the autocompletion feature on the shell, when accessing win partitions, but I thought it was a "problem" of the autocompletion, doing exact match... I did't think it was a real possibility of the fs... if it is so, i.e. ntfs is not intrinsecally case-ignorant, then there must be a way to create File and FILE, and access them, also on windows (using proper tools dealing "directly" with the fs)! That's really interesting to me!
ShinTakezou
I thought there would be an option to mount file systems case-insensitively, but apparently there isn't, at least not in ntfs-3g. It is indeed possible to do this on Windows, see e.g. http://www.cygwin.com/cygwin-ug-net/using-specialnames.html
reinierpost
+1  A: 

Well I can only tell you that you need to change the case of those header files. I don't know that there is any way you can make it automatic but still you can use cscope to do it in a easier way.

http://www.linux-tutorial.info/modules.php?name=ManPage&sec=1&manpage=cscope

Kumar Alok
+5  A: 

You'll have to fix everything by hand and rename every file or fix every place with #include. Even if you have a huge project (comparable with linux kernel), it should be possible to do this during a hour or two. Automation may be possible, but manual way should be better - because script won't be able to guess which name is right - filename, or the name used in #include.

Besides, this situation is a fault of original project developer. If he/she wasn't sloppy and named every header in every #include correctly, this wouldn't happen. Technically, this is a code problem similar to syntax error. The only right way to deal with it is to fix it.

SigTerm
Automation is possible if you adopt a rule like "all header filenames shall be entirely lowercase".
caf
All-lowercase is so ugly.
ern0
all lowercase is so fine; if you like all Capitalized, or ThIs_WAy is fine but the only important tasteless matter is that you __must__ be coherent and write it __always__ the sameway, even if your filesystem doesn't care
ShinTakezou
@caf: "all lowercase" may not be acceptable, depending on project design. Take a look at how Qt 4 manages header. Class (like QLayout) normally corresponds to header and header uses same name/case as a class.
SigTerm
+2  A: 

I think it takes not too long to write a small script, which goes thru the directories first, then replaces C headers. Explained:

  1. Scan the headers' folder and collect filenames.
  2. Make a lowercase list of them. You have now original and locased pairs.
  3. Scan the C source files and find each line contains "#include"
  4. Lowercase it.
  5. Find the lowercase filename in the list collected and lowercased from headers.
  6. Replace the source line with the one collected from headers.

You should put the modified files into a separate folder structure, avoid overwriting the whole source with some buggy stuff. Don't forget to create target folders during the source tree scan.

I recommend a script language for that task, I prefer PHP, but just it's the only server-side script language which I know. Yep, it will run for a while, but only once.

(I bet that you will have other difficulties with that project, this problem is not a typical indicator of high quality work.)

ern0
The time you'll spend writing and debugging script will be comparable to time you'll spend fixing it by hand. Plus, you'll need to do that just once, not 5 times during every day. IMO, making script isn't worth it.
SigTerm
A: 

I use the find all and replace all functionality of Source Insight when i have to do complete replacement. But your problem seems quite big, but you can try the option to replace every header file name in all occurences of source files using the "Find All" + "Replace" functionality. You can use notepad++ too for doing the same.

Praveen S
A: 

A long time ago there was a great tool under MPW (Macintosh Programmer's Workshop) called Canon. It was used to canonize text files, i.e. make all symbols found in a given refernce list have have the same usage of upper/lower case. This tool would be ideal for a task like this - I wonder if anything similar exists under Linux ?

Paul R